﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WorkSpace.Core;
using System.Data;
using System.ServiceModel;

namespace WorkSpace.TaskProxy
{
    public class OATaskQuery : ITaskQuery
    {
        public string Url { get; set; }

        public OATaskQuery(string url)
        {
            Url = url;
        }

        public int Query(string account)
        {
            System.ServiceModel.Channels.Binding binding = new System.ServiceModel.BasicHttpBinding();

            OARef.ExternalServiceSoapClient client = new OARef.ExternalServiceSoapClient(binding, new EndpointAddress(Url));
            DataSet ds = client.GetMyTask(account, 1);
            if (ds != null && ds.Tables.Count > 0)
            {
                return ds.Tables[0].Rows.Count;
            }
            return 0;
        }
    }
}
